<template>
  <div class="welfare-list">
    <div class="mescroll"  ref="mescroll">
      <div class="list">
        <div v-for="item in lists" class="item">
          <div class="left">
            <p class="title">{{item.title}}</p>
            <p class="time">{{item.create_time}}</p>
          </div>
          <div class="right">{{item.money}}元</div>
        </div>
      </div>
      <div class="none" v-show="noDate">
        <img src="@/assets/sousuomendian04.png" alt="">
        <p>暂无相关内容</p>
      </div>
    </div>
  </div>
</template>

<script>
  import {welfarelist} from '@/api/api'
  import MeScroll from 'mescroll.js'
  import 'mescroll.js/mescroll.min.css'
  export default {
    components: {
    },
    data () {
      return {
        lists:[],
        mescroll: null, //mescroll实例对象
        noDate: false,
      }
    },
    created () {
      this.id =(this.$route.query.id) ? this.$route.query.id : 0
    },
    mounted () {
      this.mescroll = new MeScroll(this.$refs.mescroll, { 
        up: {
          callback: this.upCallback
        }
      })
    },
    methods: {
      upCallback (page) {      
        welfarelist(this.id,page.num, page.size).then((res) => {
          console.log(res)
          if (page.num == 1){
            this.lists = []
          }
          if(res.data == null){
            console.log(1)
            this.mescroll.endErr()
            return
          }
          this.$nextTick(() => {
            this.mescroll.endSuccess(res.data.data.list.length)
          })
          this.lists = this.lists.concat(res.data.data.list)
          if(this.lists.length == 0){
            this.noDate = true
          }
        }).catch((err) => {
          console.dir(err)
          this.mescroll.endErr()
        })
      },
    }
  }
</script>

<style lang="stylus" scoped>
.welfare-list
  width 100%
  height 100vh
  background-color #f5f5f5
  .mescroll
    position fixed
    top 0
    bottom 0
    height auto
    width 100vw
    overflow-x hidden
    .item
      display flex
      height 7rem
      background-color #fff
      padding 0 1.6rem
      border-bottom 1px solid #e6e6e6
      &:last-child
        border none
      .left
        flex 3
        .title
          font-size 1.5rem
          color #333
          overflow hidden
          white-space nowrap
          text-overflow ellipsis
          line-height 2rem
          height 2rem
          margin-bottom .4rem
          width 25rem
          margin-top 1.5rem
        .time
          color #999
          font-size 1.2rem
          line-height 1.6rem
          height 1.6rem
      .right
        flex 1
        color #333
        font-weight bold
        font-size 1.5rem
        line-height 7rem
        text-align right
  .none
    img
      position absolute
      top 20.3rem
      width 7.25rem
      left 50%
      margin-left -3.625rem
    p
      color #666
      font-size 1.3rem
      text-align center
      position absolute
      width 100%
      top 32rem
</style>
